package com.ruoyi.teaching.service.impl;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import com.alibaba.nacos.common.utils.CollectionUtils;
import com.ruoyi.teaching.domain.Student;
import com.ruoyi.teaching.domain.vo.ExamRecordBo;
import com.ruoyi.teaching.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.teaching.mapper.ExamDetailMapper;
import com.ruoyi.teaching.domain.ExamDetail;
import com.ruoyi.teaching.service.IExamDetailService;

/**
 * 学生成绩详情Service业务层处理
 *
 * @author sunshine
 * @date 2024-01-24
 */
@Service
public class ExamDetailServiceImpl implements IExamDetailService
{
    @Autowired
    private ExamDetailMapper examDetailMapper;

    @Autowired
    private StudentMapper studentMapper;
    /**
     * 查询学生成绩详情
     *
     * @param id 学生成绩详情主键
     * @return 学生成绩详情
     */
    @Override
    public ExamDetail selectExamDetailById(Long id)
    {
        return examDetailMapper.selectExamDetailById(id);
    }

    /**
     * 查询学生成绩详情列表
     *
     * @param examDetail 学生成绩详情
     * @return 学生成绩详情
     */
    @Override
    public List<ExamDetail> selectExamDetailList(ExamDetail examDetail)
    {
        return examDetailMapper.selectExamDetailList(examDetail);
    }

    /**
     * 新增学生成绩详情
     *
     * @param examDetail 学生成绩详情
     * @return 结果
     */
    @Override
    public int insertExamDetail(ExamDetail examDetail)
    {
        return examDetailMapper.insertExamDetail(examDetail);
    }

    /**
     * 修改学生成绩详情
     *
     * @param examDetail 学生成绩详情
     * @return 结果
     */
    @Override
    public int updateExamDetail(ExamDetail examDetail)
    {
        return examDetailMapper.updateExamDetail(examDetail);
    }

    /**
     * 批量删除学生成绩详情
     *
     * @param ids 需要删除的学生成绩详情主键
     * @return 结果
     */
    @Override
    public int deleteExamDetailByIds(Long[] ids)
    {
        return examDetailMapper.deleteExamDetailByIds(ids);
    }

    /**
     * 删除学生成绩详情信息
     *
     * @param id 学生成绩详情主键
     * @return 结果
     */
    @Override
    public int deleteExamDetailById(Long id)
    {
        return examDetailMapper.deleteExamDetailById(id);
    }



    @Override
    public List<ExamDetail> selectExamDetailListByClassesId(Integer classesId) {
//        List<Student> studentList = studentMapper.selectStudentByClassesId(classesId);
//        if (CollectionUtils.isEmpty(studentList)) {
//            return Collections.emptyList();
//        }
//        return studentList.stream()
//                .map(student -> ExamDetail.builder().student(student.getName()).userId(student.getId()).build())
//                .collect(Collectors.toList());
        return examDetailMapper.selectListByClassId(classesId);
    }

    @Override
    public List<ExamDetail> selectExamRecordBoById(Long id) {

        return examDetailMapper.selectExamDetailBoById(id);
    }

    @Override
    public List<ExamDetail> selectExamDetailListByClasses(Integer id) {
        return examDetailMapper.selectExamDetailBoByClassId(id);
    }


}
